#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	char arr[100];
	fgets(arr, 100, stdin);
	unsigned int m = strlen(arr) - 1;
	int s;
	scanf("%d", &s);
	for (int i = 0; i < s; i++)
	{
		char tmp;
		tmp = arr[0];
		for (int j=0; j < m - 1; j++)
		{
			arr[j] = arr[j + 1];
		}
		arr[m - 1] = tmp;
	}
	printf("%s", arr);
	return 0;
}